﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OracleClient;
public partial class book_select : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }
    public void BindData()
    {
        string connet = "Data Source=orcl;User ID=booksale;Password=Qwertyuiop1;Unicode=True";
        string sqlstr = "select * from booksale.orderdetails order by 订单号";
        OracleConnection con = new OracleConnection(connet);
        OracleDataAdapter da = new OracleDataAdapter(sqlstr, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataKeyNames = new string[] { "订单号" };
        GridView1.DataBind();


    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        string connet = "Data Source=orcl;User ID=booksale;Password=Qwertyuiop1;Unicode=True";
        string sqlstr = "select * from booksale.orderdetails where 订单号='" + ordernum.Text + "' or 商品名称='" + ordername.Text + "' or 付款时间=to_date('" + orderdate.Text + "','yyyy-mm-dd') or 状态='" + DropDownList1.SelectedValue.ToString() + "'";
        OracleConnection con = new OracleConnection(connet);
        OracleDataAdapter da = new OracleDataAdapter(sqlstr, con);
        DataSet ds = new DataSet();
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataKeyNames = new string[] { "订单号" };
        GridView1.DataBind();
    }




    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindData();
    }
}